<template>
  <div class="rich-text-toolbar" v-if="toolbars !== ''" @mousedown.prevent="onMousedown">
    <font-size v-if="toolbars.includes('fontSize')"></font-size>
    <bold v-if="toolbars.includes('bold')"></bold>
    <italic v-if="toolbars.includes('italic')"></italic>
    <under-line v-if="toolbars.includes('underline')"></under-line>
    <font-color v-if="toolbars.includes('fontColor')"></font-color>
    <insert-fill-space v-if="toolbars.includes('fillSpace')"></insert-fill-space>
    <!-- <upload-img></upload-img> -->
    <template v-if="toolbars.includes('fullEditor')">
      <div class="spliter"></div>
      <full-editor></full-editor>
    </template>
  </div>
</template>

<script>
// TODO 拆分 item btn
import FontSize from './components/FontSize.vue'
import Bold from './components/Bold.vue'
import Italic from './components/Italic.vue'
import UnderLine from './components/UnderLine.vue'
import FontColor from './components/FontColor.vue'
import InsertFillSpace from './components/InsertFillSpace.vue'
// import UploadImg from "./components/UploadImg.vue";
import FullEditor from './components/FullEditor.vue'
export default {
  components: {
    FontSize,
    Bold,
    Italic,
    UnderLine,
    FontColor,
    InsertFillSpace,
    // UploadImg,
    FullEditor,
  },
  props: {
    toolbars: {
      type: String,
      default: 'fontSize,bold,italic,underline,fontColor,fullEditor', // fillSpace
    },
  },
  inject: ['getSelectStyleObj', 'resetSelection'],
  data() {
    return {}
  },
  computed: {},
  watch: {},
  methods: {
    onMousedown() {
      this.resetSelection()
    },
  },
}
</script>

<style lang="scss" scoped>
.rich-text-toolbar {
  position: absolute;
  top: -28px;
  left: 0px;
  height: 28px;
  white-space: nowrap;
  z-index: 4;
  background-color: #fff;
  box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  padding: 0 2px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  overflow: hidden;
  padding: 2px 4px;
  user-select: none;
  .spliter {
    margin: 0 2px;
    width: 1px;
    height: 100%;
    background: #e3e3e3;
  }
}
</style>
